local skel = fk.CreateSkill {
  name = "emo__gongli",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["emo__gongli"] = "共砺",
  [":emo__gongli"] = "锁定技，当你发动〖欢思〗后，令每个友武将或<a href='emo_friends'>好友武将</a>随机获得一个“欢思”标记。",

  ["emo_friends"] = "铝宝，Ralph，Notify，hospair，xxyheaven，youmukon，祈，蕾姆，祭祀……等等<br>（若缺少您，请联系我！）",
}

--- 友名单
local friends = {
  "emoprincess", "friend", "emotest",
  "ralph", "0t", "Notify", "n_zy", "n_wch", "hospair", "xxyheaven", "youmukon",
  "moesp__qi", "que__qi", "que__qiuli", "rem", "songweizl", "qingtianwawa", "jiaxu",
  "jisi", "yyuaN", "th_kogasa", "tangyuan", "pubcat", "miaomiao", "pangpang", "zhukuli", "lvbao", "rmt__xie",
  "wuming",
}

skel:addEffect(fk.AfterSkillEffect, {
  anim_type = "support",
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and data.skill and not data.skill.is_delay_effect
    and data.skill.name == "emo__huansi"
  end,
  on_trigger = function (self, event, target, player, data)
    local tos = table.filter(player.room:getAlivePlayers(), function (to)
      return not not (table.find(friends, function(s) return string.find(to.general, s) ~= nil end)
      or (to.deputyGeneral ~= "" and table.find(friends, function(s) return string.find(to.deputyGeneral, s) ~= nil end)))
    end)
    if #tos == 0 then return end
    event:setCostData(self, { tos = tos })
    self:doCost(event, target, player, data)
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local suits = {"log_spade", "log_heart", "log_diamond", "log_club"}
    for _, to in ipairs(event:getCostData(self).tos) do
      local rest = table.filter(suits, function (s)
        return not table.contains(to:getTableMark("@emo__huansi"), s)
      end)
      if #rest > 0 then
        room:addTableMark(to, "@emo__huansi", table.random(rest))
      end
    end
  end,
})

return skel
